package com.teaRestaurant.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaRestaurant.domain.DTO.OrderPageQueryDTO;
import com.teaRestaurant.domain.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrderMapper extends BaseMapper<Orders> {
    List<Orders> list(OrderPageQueryDTO orderPageQueryDTO);

    void insertOrder(Orders orders);

    Orders getById(String orderNo);

    Double getTurnover(LocalDateTime begin, LocalDateTime end);

    Integer getOrderCount(LocalDateTime begin, LocalDateTime end, Integer status);

    Double getAvgOrderMoney(LocalDateTime begin, LocalDateTime end);

    @Update("update orders set status = #{status} where order_no = #{orderNo}")
    void updateStatus(String orderNo, Integer status);



    List<Long> getOrderNos(LocalDateTime thirtyDaysAgo);
}
